package com.ruicar.afs.cloud.basic.system.controller;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.ruicar.afs.cloud.basic.system.dto.SystemDate;
import com.ruicar.afs.cloud.batch.service.AfsBatchInfoService;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@AllArgsConstructor
@RequestMapping("/system")
public class SystemInfoController {
    private final AfsBatchInfoService afsBatchInfoService;
    @GetMapping("/date")
    public IResponse<SystemDate> systemDate(){
        Long timeStamps = System.currentTimeMillis();
        SystemDate systemDate = SystemDate.builder()
                .timeStamps(timeStamps)
                .bhDate(afsBatchInfoService.getSystemBatchInfoWithOutUpdate("icos").getBatchDate())
                .systemDate(DateUtil.format(new Date(timeStamps), DatePattern.NORM_DATETIME_PATTERN))
                .build()
                ;
        return IResponse.success(systemDate);
    }
}
